home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / ANSI.SWG / 0008_Detect ANSI.SYS Installed.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  59 lines

  1. {
  2. The following Functions provide a way to determine if the machine
  3. the your application is running on has ANSI installed.
  4.  
  5. if your Program is written using the Crt Unit the Function may return
  6. the result as False even if ANSI is present, unless you successfully
  7. use a 'work around' method to ensure all Writes go through Dos.
  8.  
  9. I find it's easier just to not use Crt if my Program is working With
  10. ANSI - since there is not much that you use the Crt Unit For that can't
  11. be done in some other way.
  12.  
  13. The Dos-based alternatives to ReadKey and KeyPressed are included since
  14. they are needed For the AnsiDetect Function.
  15. }
  16.  
  17. Uses
  18.   Dos;
  19.  
  20. Function KeyPressed : Boolean;
  21.   { Detects whether a key is pressed. Key remains in kbd buffer}
  22. Var
  23.   r: Registers;
  24. begin
  25.   r.AH := $0B;
  26.   MsDos(r);
  27.   KeyPressed := (r.AL = $FF)
  28. end;
  29.  
  30. Function ReadKey : Char;
  31. Var
  32.   r: Registers;
  33. begin
  34.   r.AH := $08;
  35.   MsDos(r);
  36.   ReadKey := Chr(r.AL)
  37. end;
  38.  
  39. Function AnsiDetected: Boolean;
  40. { Detects whether ANSI is installed }
  41. Var
  42.   dummy: Char;
  43. begin
  44.   Write(#27'[6n');               { Ask For cursor position report via }
  45.   if not KeyPressed              { the ANSI driver. }
  46.   then
  47.     AnsiDetected := False
  48.   else
  49.   begin
  50.     AnsiDetected := True;
  51.     { empty the keyboard buffer }
  52.     Repeat Dummy := ReadKey Until not KeyPressed
  53.   end
  54. end;
  55.  
  56. begin
  57. end.
  58.  
  59.